// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   PropertiesReader.java

package include.data_backup;

import java.io.FileInputStream;
import java.net.URL;
import java.util.Properties;

public class PropertiesReader
{

	private Properties properties;

	public PropertiesReader()
	{
		this("db.properties");
	}

	public PropertiesReader(String file)
	{
		String separator = System.getProperty("file.separator");
		String strClassName = getClass().getName();
		String strPackageName = "";
		if (getClass().getPackage() != null)
			strPackageName = getClass().getPackage().getName();
		String strClassFileName = "";
		if (!"".equals(strPackageName))
			strClassFileName = strClassName.substring(strPackageName.length() + 1, strClassName.length());
		else
			strClassFileName = strClassName;
		URL url = getClass().getResource((new StringBuilder(String.valueOf(strClassFileName))).append(".class").toString());
		String strURL = url.toString();
		strURL = strURL.substring(strURL.indexOf('/') + 1, strURL.lastIndexOf('/'));
		String strURL2 = strURL.substring(0, strURL.lastIndexOf("WEB-INF"));
		String strURL1 = (new StringBuilder(String.valueOf(strURL2))).append("WEB-INF/classes").toString();
		file = (new StringBuilder(String.valueOf(strURL1))).append(separator).append("conf").append(separator).append(file).toString();
		properties = new Properties();
		try
		{
			FileInputStream in = new FileInputStream(file);
			properties.load(in);
			in.close();
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
	}

	public String getProperty(String name)
	{
		if (properties == null)
			return null;
		else
			return properties.getProperty(name);
	}
}
